package com.miyake.dsp;

import com.miyake.dsp.analyzer.FftImplScilab;
import com.miyake.dsp.circuit.RcOctave;
import com.miyake.dsp.circuit.RcScilab;
import com.miyake.dsp.circuit.RcSetting;
import com.miyake.dsp.converter.AbsoluteImplScilab;
import com.miyake.dsp.converter.AmplifierScilab;
import com.miyake.dsp.converter.AmplifierSetting;
import com.miyake.dsp.converter.DiffImplScilab;
import com.miyake.dsp.converter.Digitizer;
import com.miyake.dsp.converter.DigitizerSetting;
import com.miyake.dsp.converter.MovingAverageScilab;
import com.miyake.dsp.converter.MovingAverageSetting;
import com.miyake.dsp.converter.OffsetImplScilab;
import com.miyake.dsp.converter.OffsetSetting;
import com.miyake.dsp.convolution.ConvolutionImplOctave;
import com.miyake.dsp.convolution.ConvolutionImplScilab;
import com.miyake.dsp.convolution.ConvolutionSetting;
import com.miyake.dsp.filter.Filter;
import com.miyake.dsp.filter.FilterImplScilabProxy;

public class OptimizedFactory implements ProcessorFactory {

	private double frequency;

	public OptimizedFactory(double frequency) {
		this.setSamplingFrequency(frequency);
	}
	
	@Override
	public Processor createDiff() {
		return new DiffImplScilab();
	}

	@Override
	public Processor createFFT() {
		return new FftImplScilab();
	}

	@Override
	public void setSamplingFrequency(double frequency) {
		this.frequency = frequency;
	}

	@Override
	public Processor createConvolution(ConvolutionSetting setting) {
		return new ConvolutionImplOctave(setting);
	}

	@Override
	public Processor createAbsolute() {
		return new AbsoluteImplScilab();
	}

	@Override
	public Processor createOffset(OffsetSetting setting) {
		return new OffsetImplScilab(setting);
	}

	@Override
	public Filter createFilter(com.miyake.dsp.filter.FilterSetting setting) {
		setting.setFrequency(frequency);
		return new FilterImplScilabProxy(setting);
	}

	@Override
	public Processor createRc(RcSetting setting) {
		setting.setFrequency(frequency);
		return new RcOctave(setting);
	}

	@Override
	public Processor createMovingAverage(MovingAverageSetting setting) {
		return new MovingAverageScilab(setting);
	}

	@Override
	public Processor createAmplifier(AmplifierSetting setting) {
		return new AmplifierScilab(setting);
	}

}
